<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
  <meta charset="utf-8">
  <title>登录</title>
  <script src="command/echarts/echarts.min.js"></script>

  <script src="command/jquery/jquery-3.4.1.js"></script>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta charset="UTF-8" />

  <!-- Bootstrap -->
  <link href="assets/css/vendor/bootstrap/bootstrap.min.css" rel="stylesheet">
  <link href="http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
  <link rel="stylesheet" href="assets/css/vendor/bootstrap-checkbox.css">

  <link href="assets/css/minimal.css" rel="stylesheet">

  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
  <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
  <![endif]-->
</head>

<body class="bg bg-1">


<!-- Wrap all page content here -->
<div id="wrap">
  <!-- Make page fluid -->
  <div class="row">
    <!-- Page content -->
    <div id="content" class="col-md-12 full-page login">
      <div class="inside-block">
        <img src="assets/images/logo-big.png" alt class="logo">
        <h1><strong>欢迎您</strong> 陌生人</h1>
        <form id="form-signin" class="form-signin" method="post">
          <section>
            <div class="input-group">
              <input type="text" id="username" class="form-control" name="username" placeholder="用户名">
              <div class="input-group-addon"><i class="fa fa-user"></i></div>
            </div>
            <div class="input-group">
              <input type="password" id="password" class="form-control" name="password" placeholder="密码">
              <div class="input-group-addon"><i class="fa fa-key"></i></div>
            </div>
          </section>
          <section class="controls">
            <div class="checkbox check-transparent">
              <input type="checkbox" value="1" id="remember" checked>
              <label for="remember">记住我</label>
            </div>
          </section>
          <section class="log-in">
            <button class="btn btn-greensea" type="button" onclick="log()">登入</button>
            <span>或</span>
            <button class="btn btn-slategray"  type="button" onclick="regist()">注册</button>
          </section>
        </form>
      </div>


    </div>
    <!-- /Page content -->
  </div>
</div>

<script>
  function log(){
    let username=$('#username').val();
    let password=$('#password').val();
    console.log(username+"  "+password);
    $.ajax({
      type:"POST",
      data:{
        "username": username,
        "password": password
      },
      url:"/login/form",
      async:false,
      success:function (result) {
        if (result!=null) {
          sessionStorage.setItem("username",username);
          sessionStorage.setItem("uid",result.userinfo.id);
          sessionStorage.setItem("token",result.sessionid);
          sessionStorage.setItem("pic",result.userinfo.pic);
          sessionStorage.setItem("bg",result.userinfo.bg);
          window.location.href="/index";
        }
        else alert("登录失败!");
      },
      error :function(errorMsg) {
        alert("登录失败");
      }
    });
  }
  function regist() {
      window.location.href="/register";
  }
</script>
</body>
</html>

